import 'package:flutter/material.dart';
import 'package:latlong2/latlong.dart';

class LocationCard extends StatelessWidget {
  final LatLng location;
  final String locationName; // 假设已通过逆地理编码获取
  final VoidCallback onAdd;
  final VoidCallback onCancel;

  const LocationCard({
    required this.location,
    required this.locationName,
    required this.onAdd,
    required this.onCancel,
  });

  @override
  Widget build(BuildContext context) {
    return Card(
      elevation: 8,
      margin: EdgeInsets.all(16),
      shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)),
      child: Padding(
        padding: EdgeInsets.all(16),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          crossAxisAlignment: CrossAxisAlignment.start,
          children: [
            Text(
              '📍$locationName',
              style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
              overflow: TextOverflow.ellipsis,
              maxLines: 3,
            ),
            SizedBox(height: 8),
            Column(
              mainAxisAlignment: MainAxisAlignment.end,
              children: [
                TextButton.icon(
                  onPressed: () {
                    onAdd();
                    onCancel();
                  },
                  icon: Icon(Icons.add_location, color: Colors.green),
                  label: Text("添加标记"),
                ),
                SizedBox(width: 8),
                TextButton.icon(
                  onPressed: onCancel,
                  icon: Icon(Icons.cancel, color: Colors.red),
                  label: Text("取消"),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
